<?php
class TDGMostrarAnuncios{

	function getAnuncios(){
		session_start();  
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		$resultado = mysql_query("SELECT ID,NombreProyecto FROM anuncio");
		mysql_close($connection);
		return $resultado;
	}

	function buscar($texto, $campo){
		session_start();  
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		$resultado = mysql_query("SELECT ID,NombreProyecto FROM anuncio WHERE $campo LIKE '%$texto%';");
		mysql_close($connection);
		return $resultado;
	}
	
	function filtrarFac($id){
		session_start();  
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		$resultado = mysql_query("SELECT ID,NombreProyecto FROM anuncio WHERE Facultad= '$id';");
		ECHO $resultado;
		mysql_close($connection);
		return $resultado;
	}
	
	function filtrarUA($id){
		session_start();  
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		$resultado = mysql_query("SELECT ID,NombreProyecto FROM anuncio WHERE UnidadAcademica=$id;");
		ECHO $resultado;
		mysql_close($connection);
		return $resultado;
	}
	
	
	function getFacultades(){
		session_start();  
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		$resultado = mysql_query("SELECT * FROM facultad");
		mysql_close($connection);
		return $resultado;
	}
	
	function getUAs(){
		session_start();  
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		$resultado = mysql_query("SELECT * FROM UA");
		mysql_close($connection);
		return $resultado;
	}
	
	function obtenerCarpetas(){
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		if (!$connection){
            die('Error al conectarse a la base de datos:'. mysql_error());
		}
		$db = mysql_select_db("a83527",$connection);
		
		return mysql_query("SELECT * FROM carpeta WHERE Padre <> 'NULL' OR Padre = '0';");
	}
	
	function obtenerAnuncios(){
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		if (!$connection){
            die('Error al conectarse a la base de datos:'. mysql_error());
		}
		$db = mysql_select_db("a83527",$connection);
		
		return mysql_query("SELECT * FROM anuncio WHERE Activo = '1' AND Clasificado = '1';");
	}
}
?>